package cc.example.mybatislike.db.zeus.mapper;

import static cc.example.mybatislike.db.zeus.mapper.TaskDetailDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.example.mybatislike.db.zeus.entity.TaskDetail;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TaskDetailMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    BasicColumn[] selectList = BasicColumn.columnList(TaskDetailDynamicSqlSupport.id, TaskDetailDynamicSqlSupport.taskId, TaskDetailDynamicSqlSupport.firstReachHost, TaskDetailDynamicSqlSupport.profilesEnv, TaskDetailDynamicSqlSupport.createTime, TaskDetailDynamicSqlSupport.updateTime);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @Options(useGeneratedKeys=true,keyProperty="record.id")
    int insert(InsertStatementProvider<cc.example.mybatislike.db.zeus.entity.TaskDetail> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @Insert({
        "${insertStatement}"
    })
    @Options(useGeneratedKeys=true,keyProperty="records.id")
    int insertMultiple(@Param("insertStatement") String insertStatement, @Param("records") List<cc.example.mybatislike.db.zeus.entity.TaskDetail> records);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(MultiRowInsertStatementProvider<cc.example.mybatislike.db.zeus.entity.TaskDetail> multipleInsertStatement) {
        return insertMultiple(multipleInsertStatement.getInsertStatement(), multipleInsertStatement.getRecords());
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TaskDetailResult")
    Optional<cc.example.mybatislike.db.zeus.entity.TaskDetail> selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TaskDetailResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="task_id", property="taskId", jdbcType=JdbcType.BIGINT),
        @Result(column="first_reach_host", property="firstReachHost", jdbcType=JdbcType.VARCHAR),
        @Result(column="profiles_env", property="profilesEnv", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<cc.example.mybatislike.db.zeus.entity.TaskDetail> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(TaskDetailDynamicSqlSupport.id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(cc.example.mybatislike.db.zeus.entity.TaskDetail record) {
        return MyBatis3Utils.insert(this::insert, record, TaskDetailDynamicSqlSupport.taskDetail, c ->
            c.map(TaskDetailDynamicSqlSupport.taskId).toProperty("taskId")
            .map(TaskDetailDynamicSqlSupport.firstReachHost).toProperty("firstReachHost")
            .map(TaskDetailDynamicSqlSupport.profilesEnv).toProperty("profilesEnv")
            .map(TaskDetailDynamicSqlSupport.createTime).toProperty("createTime")
            .map(TaskDetailDynamicSqlSupport.updateTime).toProperty("updateTime")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertMultiple(Collection<cc.example.mybatislike.db.zeus.entity.TaskDetail> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TaskDetailDynamicSqlSupport.taskDetail, c ->
            c.map(TaskDetailDynamicSqlSupport.taskId).toProperty("taskId")
            .map(TaskDetailDynamicSqlSupport.firstReachHost).toProperty("firstReachHost")
            .map(TaskDetailDynamicSqlSupport.profilesEnv).toProperty("profilesEnv")
            .map(TaskDetailDynamicSqlSupport.createTime).toProperty("createTime")
            .map(TaskDetailDynamicSqlSupport.updateTime).toProperty("updateTime")
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(cc.example.mybatislike.db.zeus.entity.TaskDetail record) {
        return MyBatis3Utils.insert(this::insert, record, TaskDetailDynamicSqlSupport.taskDetail, c ->
            c.map(TaskDetailDynamicSqlSupport.taskId).toPropertyWhenPresent("taskId", record::getTaskId)
            .map(TaskDetailDynamicSqlSupport.firstReachHost).toPropertyWhenPresent("firstReachHost", record::getFirstReachHost)
            .map(TaskDetailDynamicSqlSupport.profilesEnv).toPropertyWhenPresent("profilesEnv", record::getProfilesEnv)
            .map(TaskDetailDynamicSqlSupport.createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(TaskDetailDynamicSqlSupport.updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<cc.example.mybatislike.db.zeus.entity.TaskDetail> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<cc.example.mybatislike.db.zeus.entity.TaskDetail> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default List<cc.example.mybatislike.db.zeus.entity.TaskDetail> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default Optional<cc.example.mybatislike.db.zeus.entity.TaskDetail> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(TaskDetailDynamicSqlSupport.id, isEqualTo(id_))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TaskDetailDynamicSqlSupport.taskDetail, completer);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateAllColumns(cc.example.mybatislike.db.zeus.entity.TaskDetail record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(TaskDetailDynamicSqlSupport.taskId).equalTo(record::getTaskId)
                .set(TaskDetailDynamicSqlSupport.firstReachHost).equalTo(record::getFirstReachHost)
                .set(TaskDetailDynamicSqlSupport.profilesEnv).equalTo(record::getProfilesEnv)
                .set(TaskDetailDynamicSqlSupport.createTime).equalTo(record::getCreateTime)
                .set(TaskDetailDynamicSqlSupport.updateTime).equalTo(record::getUpdateTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(cc.example.mybatislike.db.zeus.entity.TaskDetail record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(TaskDetailDynamicSqlSupport.taskId).equalToWhenPresent(record::getTaskId)
                .set(TaskDetailDynamicSqlSupport.firstReachHost).equalToWhenPresent(record::getFirstReachHost)
                .set(TaskDetailDynamicSqlSupport.profilesEnv).equalToWhenPresent(record::getProfilesEnv)
                .set(TaskDetailDynamicSqlSupport.createTime).equalToWhenPresent(record::getCreateTime)
                .set(TaskDetailDynamicSqlSupport.updateTime).equalToWhenPresent(record::getUpdateTime);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(cc.example.mybatislike.db.zeus.entity.TaskDetail record) {
        return update(c ->
            c.set(TaskDetailDynamicSqlSupport.taskId).equalTo(record::getTaskId)
            .set(TaskDetailDynamicSqlSupport.firstReachHost).equalTo(record::getFirstReachHost)
            .set(TaskDetailDynamicSqlSupport.profilesEnv).equalTo(record::getProfilesEnv)
            .set(TaskDetailDynamicSqlSupport.createTime).equalTo(record::getCreateTime)
            .set(TaskDetailDynamicSqlSupport.updateTime).equalTo(record::getUpdateTime)
            .where(TaskDetailDynamicSqlSupport.id, isEqualTo(record::getId))
        );
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(TaskDetail record) {
        return update(c ->
            c.set(TaskDetailDynamicSqlSupport.taskId).equalToWhenPresent(record::getTaskId)
            .set(TaskDetailDynamicSqlSupport.firstReachHost).equalToWhenPresent(record::getFirstReachHost)
            .set(TaskDetailDynamicSqlSupport.profilesEnv).equalToWhenPresent(record::getProfilesEnv)
            .set(TaskDetailDynamicSqlSupport.createTime).equalToWhenPresent(record::getCreateTime)
            .set(TaskDetailDynamicSqlSupport.updateTime).equalToWhenPresent(record::getUpdateTime)
            .where(TaskDetailDynamicSqlSupport.id, isEqualTo(record::getId))
        );
    }
}